package co.fitstart.coach.dao;

import java.util.Date;
import java.util.List;

import com.demo2do.core.persistence.annotation.Dynamic;
import com.demo2do.core.persistence.annotation.Query;
import com.demo2do.core.persistence.annotation.Variable;

import co.fitstart.entity.course.schedule.SigninRecord;
import co.fitstart.entity.principal.Principal;

@Dynamic("hibernate")
public interface SigninRecordDao {
    
    /**
     * 
     * @param coach
     * @return
     */
    @Query("FROM SigninRecord WHERE disabled = false AND mobile = true and coach = :coach ORDER BY signinTime DESC")
    public List<SigninRecord> list(@Variable("coach") Principal coach);
    
    /**
     * 
     * @param coach
     * @param startTime
     * @param endTime
     * @return
     */
    @Query("SELECT COUNT(*) FROM SigninRecord WHERE disabled = false AND mobile = true and coach = :coach AND signinTime BETWEEN :startTime AND :endTime")
    public int getDaySigninAmount(@Variable("coach") Principal coach, @Variable("startTime") Date startTime, @Variable("endTime") Date endTime);
    
    /**
     * 
     * @param coach
     * @return
     */
    @Query("SELECT COUNT(*) FROM SigninRecord WHERE disabled = false AND mobile = true and coach = :coach")
    public int getSigninAmount(@Variable("coach") Principal coach);

}
